﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using LibFriesland_Campina_CRM;
using CrystalDecisions.Shared;

public partial class UserControls_UCNaSale : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            string bySale = Request.Form["ctl00$ContentPlaceHolder1$bySale"].ToString();
            string fromDate = Request.Form["ctl00$ContentPlaceHolder1$dtFromDate"].ToString();
            string toDate = Request.Form["ctl00$ContentPlaceHolder1$dtTodate"].ToString();

            if (bySale == "NA")
            {
                string by_na = Request.Form["ctl00$ContentPlaceHolder1$cboNA"].ToString();
                DateTime dtFromDate = Convert.ToDateTime(Thuvien.myConvertStringToShortDate(fromDate));
                DateTime dtToDate = Convert.ToDateTime(Thuvien.myConvertStringToShortDate(toDate));

                LibFriesland_Campina_CRM.Dataset.DatasetNaSale ds = DalInvoiceDetail.getSalebyDateNa(dtFromDate, dtToDate, by_na);
                LibFriesland_Campina_CRM.Report.ReportNASale report = new LibFriesland_Campina_CRM.Report.ReportNASale();
                report.SetDataSource(ds);

                //Truyen tham so cho Report
                //ParameterFields paramFieldArray = new ParameterFields();
                //ParameterField paramFieldTest = new ParameterField();
                //ParameterField paramFieldDemo = new ParameterField();
                
                //paramFieldTest.Name = "pTest";  //pTest, pDemo: Ten paramfield khi thiet ke report
                //paramFieldDemo.Name = "pDemo";

                //paramFieldTest.CurrentValues.AddValue("Test");
                //paramFieldDemo.CurrentValues.AddValue("Demo");

                //paramFieldArray.Add(paramFieldTest);
                //paramFieldArray.Add(paramFieldDemo);

                //crvNaSale.ParameterFieldInfo = paramFieldArray;

                crvNaSale.ReportSource = report;
                crvNaSale.DataBind();
            }
        }
        catch (Exception ex)
        {
            
        }
    }
}